﻿@model IEnumerable<YogaStudio.WebUI.Models.StudentsViewModel>

<div class="datagrid">
    <table class="box-table-a">
        <tr>
            <th>Course</th>
            <th>Student ID</th>
            <th>Student</th>
            <th>Student's advisor</th>
            <th></th>
        </tr>

        @foreach (var item in Model)
        {
            var studentCount = 0; var numberStudents = item.Students.Count;
            <tbody>
            @foreach (var cus in item.Students)
            {
                studentCount++;
                <tr>
                    @if (studentCount == 1)
                    {
                        <td rowspan="@numberStudents">
                            @Html.DisplayFor(m => item.Course.CourseName)
                            (@item.Section.Schedule.FromDate.ToShortDateString())
                        </td>
                    }
                    <td>
                        @Html.DisplayFor(m => cus.Id)
                    </td>
                    <td>
                        @Html.DisplayFor(m => cus.FullName)
                    </td>
                    <td>
                        @Html.DisplayFor(m => cus.Advisor.FullName)
                    </td>
                    <td>
                        @Html.ActionLink("Details", "Details", "Customers", new { id = cus.Id }, null)
                    </td>
                </tr>
            }
            </tbody>
        }

    </table>
</div>